<template>
    <div>
        这是index组件内容
        <h1>这是parent----{{$store.state.count}}</h1>
        <el-button @click="addCount">自增</el-button>
 

        <child-1></child-1>
        <child-2></child-2>

        {{$store.state.list}}
        <el-button @click="setList">setList</el-button>
    </div>
</template>

<script>
import Child1 from './child1.vue'
import Child2 from './child2.vue'

export default {
    components:{
          Child1,
          Child2,
    },
    data() {
        return{
        }
    },
    methods:{
        addCount(){
            this.$store.commit('addCount')
            //不可取
            //this.$store.state.count=100
        },
        setList(state){
            this.$store.commit('setList','这是从parent接收的值')
        }
    }
}
</script>